<?php

namespace App\Models;

use App\User;
use Illuminate\Database\Eloquent\Model;

/**
 * 兼容老项目 tn_doctor表 仅做创建医生账号时，写入 tn_doctor表数据
 * Class DoctorDetail
 * @package App\Models
 */
class DoctorDetail extends Model
{
    protected $table = 'tn_doctor';

    protected $fillable = [
        'account', 'job'
    ];

    protected $primaryKey = 'ACCOUNT';

    public $timestamps = false;

    public function user()
    {
        return $this->belongsTo(User::class, 'account', 'account');
    }

    public function setJobAttribute($value)
    {
        if (is_numeric($value)) {

            return $this->attributes['JOB'] = config('custom.doctor.title')[$value];
        }

        return $this->attributes['JOB'] = null;
    }
}
